home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / c_toolbx.arc / MEMORY.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-03-30  |  3.6 KB  |  118 lines

  1. ;       memory.asm - memory access functions
  2. ;       start data section
  3.         include begdata.ha
  4.         include enddata.ha
  5. ;
  6. ;       start code section
  7. ;
  8.         include begcode.ha
  9. ;
  10. ;       peek - get a byte from another segment
  11. ;
  12. ;       USAGE: byte_value = peek(segment_address,0ffset_address) ;
  13. ;
  14. peek_args struc                 ; input arguments
  15.         dw      0               ; saved BP value
  16.         dw      0               ; return address
  17. peek_seg        dw     0        ; segment part of address
  18. peek_off        dw     0        ; offset part of the address
  19. peek_args ends
  20. ;
  21.         public  peek
  22. peek:
  23.         push    bp
  24.         mov     bp,sp           ; set our argument pointer
  25.         push    es
  26.         mov     ax,word ptr peek_seg[bp] ; load segmented address
  27.         mov     bx,word ptr peek_off[bp]
  28.         mov     es,ax
  29.         mov     al,es:byte ptr [bx]
  30.         xor     ah,ah
  31.         pop     es
  32.         pop     bp
  33.         ret
  34. ;
  35. ;
  36. ;       poke - store a byte in another segment
  37. ;
  38. ;       USAGE: poke(byte_value,segment_address,offset_address) ;
  39. ;
  40. poke_args struc                 ; input arguments
  41.         dw      0               ; saved BP value
  42.         dw      0               ; return address
  43. poke_byte       dw     0        ; byte value to store
  44. poke_seg        dw     0        ; segment part of address
  45. poke_off        dw     0        ; offset part of the address
  46. poke_args ends
  47. ;
  48.         public  poke
  49. poke:
  50.         push    bp
  51.         mov     bp,sp           ; set our argument pointer
  52.         push    es
  53.         mov     ax,word ptr poke_seg[bp] ; load segmented address
  54.         mov     bx,word ptr poke_off[bp]
  55.         mov     es,ax
  56.         mov     ax,word ptr poke_byte[bp] ; load the data value
  57.         mov     es:byte ptr [bx],al       ; write it to the port
  58.         pop     es
  59.         pop     bp
  60.         ret
  61. ;
  62. ;       lmove - move data between segments
  63. ;
  64. ;       USAGE:  lmove(dest_offset,dest_segment,source_offset,
  65. ;               source_segment,number_bytes) ;
  66. ;
  67. lmove_args struct                       ; input parameters
  68.         dw      0                       ; saved BP value
  69.         dw      0                       ; return address
  70. destseg dw      0                       ; destination segment address
  71. doff    dw      0                       ; destination offset address
  72. srcseg  dw      0                       ; source segment address
  73. soff    dw      0                       ; source offset address
  74. mbytes  dw      0                       ; number of bytes to move
  75. lmove_args ends
  76. ;
  77.         public  lmove
  78. lmove:
  79.         push    bp
  80.         mov     bp,sp                   ; set argument pointer
  81.         push    ds                      ; save register values
  82.         push    es
  83.         push    si
  84.         push    di
  85.         cld
  86.         mov     ax,word ptr destseg[bp] ; load dest. address
  87.         mov     es,ax
  88.         mov     di,word ptr doff[bp]
  89.         mov     ax,word ptr srcseg[bp]  ; load source address
  90.         mov     ds,ax
  91.         mov     si,word ptr soff[bp]
  92.         mov     cx,word ptr mbytes[bp]  ; load the byte count
  93.         rep movsb                       ; move the data
  94.         pop     di                      ; restore register values
  95.         pop     si
  96.         pop     es
  97.         pop     ds
  98.         pop     bp
  99.         ret
  100. ;
  101. ;       get_cs - get CS segment address
  102. ;       usage: cs_value = get_cs()
  103.         public  get_cs
  104. get_cs: mov     ax,cs
  105.         ret
  106. ;
  107. ;       get_ds - get DS segment address
  108. ;       usage: ds_value = get_ds()
  109.         public  get_ds
  110. get_ds: mov     ax,ds
  111.         ret
  112. ;
  113.         include endcode.ha
  114.         end
  115.  
  116.  
  117.  
  118.